package cn.jly.flink.custom;

import java.sql.Connection;
import java.sql.DriverManager;

/**
 * @author lanyangji
 */
public class MysqlUtils {
    private static final String DRIVER_CLASS = "com.mysql.jdbc.Driver";
    private static final String URL = "jdbc:mysql://192.168.88.103:3306/test?useUnicode=true&characterEncoding=UTF-8";
    private static final String USERNAME = "root";
    private static final String PASSWORD = "123456";

    private MysqlUtils() {
    }

    public static Connection getConnection() {
        Connection connection;
        try {
            Class.forName(DRIVER_CLASS);
            connection = DriverManager.getConnection(URL, USERNAME, PASSWORD);
        } catch (Exception e) {
            throw new RuntimeException(String.format("mysql connection error: %s %n", e.getMessage()));
        }

        return connection;
    }
}
